package com.wencst.security.bean;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;

import lombok.Data;
import lombok.ToString;

@Data
@ToString
public class User implements UserDetails,Serializable {

	public User(String username2, String password2, List<GrantedAuthority> auths) {
		// TODO Auto-generated constructor stub
		this.username = username2;
		this.password = password2;
		this.auths = auths;
	}
	public User() {
	}
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private String username;
	private String password;
	private String roles;
	private List<GrantedAuthority> auths;
	@Override
	public Collection<? extends GrantedAuthority> getAuthorities() {
		// TODO Auto-generated method stub
		if (auths == null) {
			auths = AuthorityUtils.commaSeparatedStringToAuthorityList(roles);
		}
		return auths;
	}
	@Override
	public boolean isAccountNonExpired() {
		return true;
	}
	@Override
	public boolean isAccountNonLocked() {
		return true;
	}
	@Override
	public boolean isCredentialsNonExpired() {
		return true;
	}
	@Override
	public boolean isEnabled() {
		return true;
	}

}
